<? 
$JO[ "Account"		] = JO( array( "EN" => "Account",																"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Tài Khoản"		) );
$JO[ "IWantTo"		] = JO( array( "EN" => "I want to...",															"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Tôi muốn..."		) );
$JO[ "FindMyAcc"	] = JO( array( "EN" => "Find My Account",														"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Tìm Tài Khoản Của Tôi"		) );
$JO[ "LogOut"		] = JO( array( "EN" => "Log Out",																"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Đăng Xuất"		) );
$JO[ "CreateAcc"	] = JO( array( "EN" => "Create An Account",														"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Tạo Một Tài Khoản"		) );
$JO[ "UpdateAcc"	] = JO( array( "EN" => "Update My Account",														"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Cập Nhật Tài Khoản Của Tôi"		) );
$JO[ "Identifier"	] = JO( array( "EN" => "Identifier",															"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Tên Đăng Nhập"		) );
$JO[ "IdMessage"	] = JO( array( "EN" => "The value of 'Identifier' might be 5 ~ 16 characters without a blank.",	"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Tên đăng Nhập có thể từ 5 đến 16 ký tự và không có khoảng trắng."		) );
$JO[ "Password"		] = JO( array( "EN" => "Password",																"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Mật Khẩu"		) );
$JO[ "PassMessage"	] = JO( array( "EN" => "The value of 'Password' might be 5 ~ 16 characters without a blank.",	"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Mật khẩu có thể từ 5 đến 16 ký tự và không có khoảng trắng."		) );
$JO[ "Name"			] = JO( array( "EN" => "Name",																	"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Tên"		) );
$JO[ "NameMessage"	] = JO( array( "EN" => "The value of 'Name' might be 5 ~ 32 characters.",						"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Tên có thể từ 5 đến 32 ký tự."		) );
$JO[ "Mail"			] = JO( array( "EN" => "Mail",																	"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Thư Điện Tử"		) );
$JO[ "Sex"			] = JO( array( "EN" => "Sex",																	"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Giới Tính"		) );
$JO[ "Male"			] = JO( array( "EN" => "Male",																	"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Nam"		) );
$JO[ "Female"		] = JO( array( "EN" => "Female",																"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Nữ"		) );
$JO[ "Phone"		] = JO( array( "EN" => "Phone",																	"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Điện Thoại"		) );
$JO[ "Address"		] = JO( array( "EN" => "Address",																"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Địa Chỉ"		) );
$JO[ "Birth"		] = JO( array( "EN" => "Birth",																	"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Ngày Sinh"		) );
$JO[ "change"		] = JO( array( "EN" => "Change Password",																	"VI" => "Thay Đổi Mật Khẩu"		) );
$JO[ "quest"		] = JO( array( "EN" => "Secret Question",																	"VI" => "Câu Hỏi Bí Nật"		) );
$JO[ "answer"		] = JO( array( "EN" => "Secret Answer",																	"VI" => "Câu Trả Lời"		) );
$JO[ "avarta"		] = JO( array( "EN" => "avarta",																	"VI" => "Hình Đại Diện"		) );
$active="create";
if(isset($_SESSION["JO_account_key"]))
$active='';
			
?>
<?

	if(isset( $_SESSION[ "JO_account_key" ]) ) {

		$query = "SELECT * FROM `account` WHERE `key` = '" . $_SESSION[ "JO_account_key" ] . "'";

		$recordSet = JO_query( $query );

		if( $recordSet -> num_rows ) $record = $recordSet -> fetch_array( );

	}

?>



<div class="JO_page">

	<h1><?=$JO["Account"];?></h1>

	<h2>&nbsp;</h2>

	<h3>&nbsp;</h3>

</div>

<div class="JO_relative" style="width: 960px;">



	<div class="JO_left">

		<div class="JO_box_240">

			<h1><?=$JO[ "IWantTo" ]?></h1>

			<? if( empty( $_SESSION[ "JO_account_key" ] ) ) { ?>

				<a
					class	= "JO_menu"
					href	= "?JO_unit=12_find<?= isset($_REQUEST[ "JO_account_return" ]) ? "&JO_account_return=" . $_REQUEST[ "JO_account_return" ] : "" ?>"
				><?=$JO[ "FindMyAcc"	]?></a>

			<? } else { ?>

				<!--<a
					class	= "JO_menu"
					href	= "#this"
				>Keep Me Logged In</a>-->

				<a
					href	= "#this"
					class	= "JO_menu"
					onclick	= "document.getElementById( 'JO_integration_asynchronous' ).src = 'JO_05_execution.php?JO_query=logOut';"
				><?=$JO[ "LogOut"	]?></a>
                <a
					href	= "?JO_unit=12_find<?= isset($_REQUEST[ "JO_account_return" ]) ? "&JO_account_return=" . $_REQUEST[ "JO_account_return" ] : "" ?>&SO_active=change"
					class	= "JO_menu"
					onclick	= ""
				><?=$JO[ "change"	]?></a>
                <a
					href	= "?JO_unit=11_01_avarta"
					class	= "JO_menu"
					onclick	= ""
				><?=$JO[ "avarta"	]?></a>

			<? } ?>

		</div>

	</div>



	<div class="JO_left">

		<form action="JO_05_execution.php" target="JO_integration_asynchronous" class="JO_bar_720" method="post" >

			<input type="hidden"						name="JO_query"				value="account"													/>
			<input type="hidden" id="JO_account_query"	name="JO_account_query"		value="<?=$active=="insert"?"":"update"?>"														/>
			<input type="hidden"						name="JO_account_return"	value="<?= urldecode( $_REQUEST[ "JO_account_return" ] ) ?>"	/>

			<h1><?= empty( $_SESSION[ "JO_account_key" ] ) ? $JO[ "CreateAcc"	] : $JO[ "UpdateAcc"	] ?></h1>

			<div>

				<table>
<!--avarta-->
					<!-- Identifier -->

						<tr >

							<th style="width: 81px;"><?=$JO[ "Identifier"	] ?><span class="JO_positive">*</span></th>

							<td
								style		= "width: 161px;"
							>
                            <?php if($active!=""){  ?>
                            <input
								type		= "text"
								name		= "JO_account_identifier"
								value		= "<?= isset($record[ "identifier"	])?$record[ "identifier"	]:""?>"
								maxlength	= "16"
								style		= "width: <?= isset($JO_IE) ? 145 : 147 ?>px; "
								onblur		= "document.getElementById( 'JO_account_query' ).value = 'identifier'; submit( );"
							/>
                            <td
								class	= "JO_middle"
							><span
								id		= "JO_account_identifier_guide"
								style	= "position: relative;"
							><?=$JO[ "IdMessage"	]?></span></td>
                            <?php  }else{ ?>
                             <input
								type		= "text"
								name		= "JO_account_identifier"
								value		= "<?= isset($_SESSION[ "JO_account_identifier"	])?$_SESSION[ "JO_account_identifier"	]:""?>"
								maxlength	= "16"
								style		= "width: <?= isset($JO_IE) ? 145 : 147 ?>px;"
								onblur		= "document.getElementById( 'JO_account_query' ).value = 'identifier'; submit( );"
                                readonly="readonly"s
							/>
                            
                            <?php  } ?>
                            </td>

							<td
								class	= "JO_middle"
							></td>

						</tr>



					<!-- Password -->

						<tr>

							<th	style="padding-top: 12px; vertical-align: top""><?=$JO[ "Password"	]?> <span class="JO_positive">*</span></th>

							<td style="vertical-align:middle;text-align:left">
								
                                 
                                 <a href="?JO_unit=12_find&SO_active=change" id="li"  <?=$active==""?"":"style='display:none'"?>><?=$JO[ "change"		]?></a>
								<input
                                	id='in'
									type		= "password"
									name		= "JO_account_password"
									value		= ""
									maxlength	= "16"
									style		= "width: <?= isset($JO_IE) ? 145 : 147 ?>px;<?=$active=='create'?"":"display:none"?>"
									onblur		= "document.getElementById( 'JO_account_query' ).value = 'password'; submit( );"
								/><br />

								<input
									type		= "password"
									name		= "JO_account_confirmation"
									value		= ""
									maxlength	= "16"
									style		= "width: <?= isset($JO_IE) ? 145 : 147 ?>px;<?=$active=='create'?"":"display:none"?>"
									onblur		= "document.getElementById( 'JO_account_query' ).value = 'confirmation'; submit( );"
								/>

							</td>

							<td	style="padding-top: 12px;">

								<span
									id		= "JO_account_password_guide"
									style	= "position: relative;<?=$active=='create'?"":"display:none"?>"
								><?=$JO[ "PassMessage"	]?></span><br /><br />

								<span
									id		= "JO_account_confirmation_guide"
									style	= "position: relative;<?=$active=='create'?"":"display:none"?>"
								></span>

							</td>

						</tr>



					<!-- Name -->

						<tr>

							<th><?=$JO[ "Name"	]?><span class="JO_positive">*</span></th>

							<td><input
								type	= "text"
								name	= "JO_account_name"
								value	= "<?= isset($record[ "name" ])?$record[ "name"	]:""?>"
								style	= "width: <?= isset($JO_IE) ? 145 : 147 ?>px;"
								onblur	= "document.getElementById( 'JO_account_query' ).value = 'name'; submit( );"
							/></td>

							<td
								class	= "JO_middle"
							><span
								id		= "JO_account_name_guide"
								style	= "position: relative;"
							><?=$JO[ "NameMessage"	]?></span></td>

						</tr>



					<!-- Mail -->

						<? $temp = explode( "\r\n", isset($record[ "mail" ])?$record[ "mail" ]:"" ); ?>

						<tr>

							<th><?=$JO[ "Mail"	]?> <span class="JO_positive">*</span></th>

							<td><input
								type	= "text"
								name	= "JO_account_mail"
								value	= "<?= $temp[ 0 ] ?>"
								style	= "width: <?= isset($JO_IE) ? 145 : 147 ?>px;"
								onblur	= "document.getElementById( 'JO_account_query' ).value = 'mail'; submit( );"
							/></td>

							<td
								class	= "JO_middle"
							><span
								id		= "JO_account_mail_guide"
								style	= "position: relative;"
							></span></td>

						</tr>



					<!-- Sex -->

						<tr>

							<th><?=$JO[ "Sex" ]?></th>

							<td><select name="JO_account_sex" style="width: 160px;">
								<option></option>
								<option value="male"	<?= isset($record[ "sex" ])?($record[ "sex" ] == "male"?"selected":	"") : "" ?>><?=$JO[ "Male"	]?>	</option>
								<option value="female"	<?= isset($record[ "sex" ])?($record[ "sex" ] == "female"?"selected":	"") : "" ?>><?=$JO[ "Female"	]?>	</option>
							</select></td>

							<td></td>

						</tr>



					<!-- Phone -->

						<? $temp = explode( "\r\n", isset($record[ "phone" ])?$record[ "phone" ]:"" ); ?>

						<tr>

							<th><?=$JO[ "Phone" ] ?></th>

							<td><input
								type	= "text"
								name	= "JO_account_phone"
								value	= "<?= $temp[ 0 ] ?>"
								style	= "width: <?= isset($JO_IE) ? 145 : 147 ?>px;"
							/></td>

							<td></td>

						</tr>



					<!-- Address -->

						<? $temp = explode( "\r\n", isset($record[ "address" ])?$record[ "address" ]:"" ); ?>

						<tr>

							<th><?=$JO[ "Address" ] ?></th>

							<td
								colspan = "2"
							><input
								type	= "text"
								name	= "JO_account_address"
								value	= "<?= $temp[ 0 ] ?>"
								style	= "width: <?=isset( $JO_IE) ? 569 : 571 ?>px;"
							/></td>

						</tr>
					<!--quest-->
					<tr>

							<th><?=$JO[ "quest" ] ?></th>

							<td
                            
                            <?php
								$quest="";
							 if(isset($_SESSION[ "JO_account_quest"		])) 
									$quest=$_SESSION[ "JO_account_quest"		]; ?>
								
							><select name="JO_account_quest" id="JO_account_quest" class="input_selecti" style	= "width: <?= isset($JO_IE) ? 145 : 160 ?>px;text-align:center " onchange="document.getElementById( 'JO_account_query' ).value = 'JO_account_quest'; submit( );"
							/>">
                                        <option value="">---Mời Chọn Câu Hỏi---</option>
                                        <option <?=$quest==1?"selected='selected'":""  ?> value="1"> Tên Trường Tiểu Học Của Bạn   </option>
                                        <option <?=$quest==2?"selected='selected'":""  ?> value="2"> Tủ Áo Của Bạn Có Bao Nhiu Cái </option>
                                        <option <?=$quest==3?"selected='selected'":""  ?> value="3" > Quyển Sách Bạn Đọc Nhiều Nhất </option>
                                        <option <?=$quest==4?"selected='selected'":""  ?> value="4"> Game Bạn Thích Chơi Nhất      </option>
                                        <option <?=$quest==5?"selected='selected'":""  ?> value="5"> Bộ Phim Bạn Thích Nhất        </option>
                                  </select></td>
	<td
								class	= "JO_middle"
							><span
								id		= "JO_account_quest_guide"
								style	= "position: relative;"
							></span></td>

						</tr>
                    <!--anwser-->
					<tr>
					<? $temp = explode( "\r\n", isset($record[ "secret_answer" ])?$record[ "secret_answer" ]:"" ); ?>
							<th><?=$JO[ "answer" ] ?></th>

							<td
							>
                            <input
								type	= "password"
								name	= "JO_account_answer"
                                id="JO_account_answer2"
								value	= "<?= $temp[ 0 ] ?>"
								onblur	= "document.getElementById( 'JO_account_query' ).value = 'JO_account_answer'; submit( );"
                                style	= "width: <?= isset($JO_IE) ? 145 : 147 ?>px;"
							/>
                           </td>
                           
                           </td>
	<td
								class	= "JO_middle"
							>
                            <span
								id		= "JO_account_answer_guide"
								style	= "position: relative;"
							>Câu Trả Lời Từ 5 kí tự</span></td>
                        
							
						</tr>
					<!-- Birth -->

						<tr>

							<th><?=$JO[ "Birth" ]?></th>

							<td>

								<select name="JO_account_birth_day" style="width: 46px; margin-right: 1px;">

									<option><?= substr( isset($record[ "birth" ])?$record[ "birth" ]:"", 8, 2 ) ?></option>

									<? for( $i = 1; $i <= 31; $i ++ ) { ?><option><?= sprintf( "%02d", $i ) ?></option><? } ?>

								</select>

								<select name="JO_account_birth_month" style="width: 46px; margin-right: 1px;">

									<option><?= substr( isset($record[ "birth" ])?$record[ "birth" ]:"", 5, 2 ) ?></option>

									<? for( $i = 1; $i <= 12; $i ++ ) { ?><option><?= sprintf( "%02d", $i ) ?></option><? } ?>

								</select>

								<select name="JO_account_birth_year" style="width: 60px; margin-right: 1px;">

									<option><?= substr( isset($record[ "birth" ])?$record[ "birth" ]:"", 0, 4 ) ?></option>

									<? for( $i = intval( date( 'Y' ) ); $i > intval( date( 'Y' ) ) - 90; $i -- ) { ?><option><?= $i ?></option><? } ?>

								</select>

							</td>

							<td></td>

						</tr>



					<!-- Submit -->

						<tr>

							<th style	= "border-bottom: 1px solid #FFFFFF; background-color: #FFFFFF;"></th>

							<td
								colspan	= "2"
								style	= "border-bottom: 1px solid #FFFFFF; background-color: #FFFFFF;"
							><input
								type	= "submit"
								value	= "<?= empty( $_SESSION[ "JO_account_key" ] ) ? $JO[ "CreateAcc" ] : $JO[ "UpdateAcc"	] ?> "							
                                id="nut"
								class	= "JO_button"
								style	= "width: 584px;"
								onclick	= "document.getElementById( 'JO_account_query' ).value = '<?= empty( $_SESSION[ "JO_account_key" ] ) ? "insert" : "update" ?>'; submit( );"
							/></td>

						</tr>



				</table>



			</div>

		</form>



	</div>

</div>
	<script>
	
	$('#sua').click(function(){
	$('#sua').hide(500)
	$('#xong').show(500)
	$('#JO_account_answer').hide(500)
	$('#JO_account_answer2').show(500)
	});
$('#xong').click(function(){
	$('#xong').hide(500)
	$('#sua').show(500)
	$('#JO_account_answer').show(500)
	$('#JO_account_answer2').hide(500)
	});
	</script>		
